var path = require('path');
var webpack = require('webpack');

var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(__dirname, './components/index.js');
var BUILD_PATH = path.resolve(__dirname, './build');
var ExtractTextPlugin = require("extract-text-webpack-plugin");//提取css

module.exports = {
	entry: [
		// 'webpack/hot/dev-server',
  	// 'webpack-dev-server/client?http://localhost:8080',
  	APP_PATH
	],
	output: {
		path: BUILD_PATH,
		filename: 'bundle.js'
	},
	module: {
		loaders: [{
			test: /\.jsx?$/,
			loaders: ['babel-loader?presets[]=es2015,presets[]=react']
		},
		{
			test: /\.less$/,
			loader: 'style!css!less'
		},
		// {
    //   test: /\.less$/,
    //   loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader")
    // },
		{
    		test: /\.(png|jpg)$/,
    		loader: 'url?limit=50000'
    	}]
	},
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
		new webpack.optimize.UglifyJsPlugin({
		 output: {
			 comments: false,  // remove all comments
		 },
		 compress: {
			 warnings: false
		 }
	 }),
	 new webpack.DefinePlugin({
      'process.env': {
          NODE_ENV: JSON.stringify(process.env.NODE_ENV),
      },
    }),
		// new ExtractTextPlugin("bundle.css")
  ],
}
